package kr.co.redbean.frame
{
	import flash.display.BitmapData;
	import flash.display.DisplayObject;
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.text.AntiAliasType;
	import flash.text.Font;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFormat;
	
	import kr.co.redbean.controls.CartButton;
	
	/*
	*
	*  class MainFrame
	*  2010.06.02 yaomplan@gmail.com
	*  웹사이트의 메인 배경이 되는 그림들 ( 선, 로고, 카피라이트등 )을 스테이지에 삽입한다.
	*/
	public class Frame extends MainFrame implements IMainFrame
	{
		[Embed(source="images/logo.png")]
		private var _logo:Class;
		[Embed(source="images/cart.png")]
		private var _cart:Class;
		
		private var _frame:Sprite;
		
		private var _logoContainer:Sprite;
		private var _logoC:DisplayObject;
		
		private var _cartContainer:CartButton;
		private var _cartC:DisplayObject;
		
		private var _cartText:CartButton;
		private var _copy:TextField;
		
		private var _posS:Object;
		private var _posF:Object;
		
		public function Frame()
		{
			super();
			_frame = new Sprite;
			_frame.mouseEnabled = false;
			_logoContainer = new Sprite;
			_cartContainer = new CartButton(true);
			_copy = new TextField;
			_cartText = new CartButton;
			_logoC = new _logo;
			_cartC = new _cart;
			
			_frame.addChild(_logoContainer);
			_frame.addChild(_cartText);
			_frame.addChild(_copy);
			_frame.addChild(_cartContainer);
			
			addChild(_frame);
			addEventListener(Event.ADDED_TO_STAGE, setPlacement);
		}
		
		public function setPlacement($e:Event=null):void {
			removeEventListener(Event.ADDED_TO_STAGE, setPlacement);
			
			graphics.clear();
			setLogoPlacement();
			setCartPlacement();
			setCartTextPlacement();
			setCopyrightPlacement();
		}
		
		private function setLogoPlacement():void {
			_logoContainer.graphics.clear();
			_logoContainer.x = posF.right - 201;
			_logoContainer.y = posF.top - MENUBAR_HEIGHT - 49;
			_logoContainer.addChild(_logoC);
		}
		private function setCartPlacement():void {
			_cartContainer.graphics.clear();
			_cartContainer.x = posF.right - 19;
			_cartContainer.y = posF.bottom + 7;
			_cartContainer.addChild(_cartC);
		}
		private function setCartTextPlacement():void {
			_cartText.x = posF.right - 165;
			_cartText.y = posF.bottom + 4;
		}
		private function setCopyrightPlacement():void {
			var tf:TextFormat;
			tf = new TextFormat;
			
			tf.align = 'right';
			tf.color = 0x777777;
			tf.letterSpacing = 0;
			tf.size = 10;
			tf.font = 'Arial';
			
			_copy.defaultTextFormat = tf;
			_copy.width = 220;
			_copy.text = 'Copyright 2010 s.j.redbean. All right reserved.';
			_copy.x = posF.right - 220;
			_copy.y = posF.bottom + 30;
		}
		override public function set alpha(value:Number):void {
			super.alpha = value;
		}
	}
}